home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programmer's Power Pack / Delphi Volume 1.iso / e_to_l / fbuilder / delphi / fb_rtti.int < prev    next >
Text File  |  1996-09-15  |  5KB  |  127 lines

  1. {$F+}
  2. {*
  3.  * FormulaBuilder 1.0
  4.  * Delphi 1.0 RTTI Unit
  5.  * Copyright (c) 1995, 1996 Clayton Collie
  6.  * All Rights Reserved
  7.  *
  8.  * Use is authorized only in accordance with a
  9.  * valid FormulaBuilder License agreement
  10.  *
  11.  *}
  12. unit fb_rtti;
  13. INTERFACE
  14. uses typinfo,sysutils,classes,forms;
  15. CONST
  16.   RTTI_INVALID_OBJECT    = 210;
  17.   RTTI_INVALID_PROPERTY  = 211;
  18.   RTTI_INVALID_PROPVALUE = 212;
  19.   RTTI_INVALID_PROPPATH  = 213;
  20.   RTTI_PROP_READONLY     = 214;
  21.  
  22. Type
  23.   RTTIError = Class(Exception)
  24.   public
  25.      Constructor Create( ecode : integer );
  26.      Property ErrorCode : integer read fErrorCode write fErrorCode;
  27.   end;
  28.  
  29.   TInstanceProperty = Class(TObject)
  30.   Private
  31.     {* Unlisted *}
  32.   Public
  33.     Constructor Create;
  34.     Constructor CreateFull(anInstance : TObject;APropInfo : PPropInfo);
  35.     Constructor CreateFromPath(root : TObject; PropPath : String);
  36.     Constructor CreateFromSearch(root : TObject;Const Propname : string;kinds : TTypeKinds);
  37.     procedure   SetEvent(ComponentWithHandler : TComponent;const Handler : string);
  38.    {Procedure   Assign(const newInstance : TInstanceProperty);}
  39.     Property AsChar     : char      read getAsChar    write setFromChar;
  40.     Property AsFloat    : extended  read getAsFloat   write setFromFloat;
  41.     Property AsInteger  : longint   read getAsInteger write setFromInteger;
  42.     Property AsBoolean  : boolean   read getAsBoolean write setFromBoolean;
  43.     Property AsMethod   : TMethod   read getAsMethod  write setFromMethod;
  44.     Property AsObject   : TObject   read getAsObject  write setFromObject;
  45.     Property AsString   : String    read getStringValue write setPropFromString;
  46.     Property Typename   : string    read getTypename;
  47.     Property TypeData   : PTypeData read getTypeData;
  48.     Property IsBoolean  : boolean   read getIsBoolean;
  49.     Property Instance   : TObject   read fInstance write setInstance;
  50.     Property IsReadOnly : boolean   read getIsReadonly;
  51.     Property IsStored   : boolean   read getIsStored;
  52.     Property isDefault  : boolean   read getisDefault;
  53.     Property Kind       : TTypeKind read getKind;
  54.     Property PropInfo   : PPropInfo read fPropInfo;
  55.     Property Propname   : string    read getname write setName;
  56.   end;
  57.   TFBPropData = TInstanceProperty;
  58.  
  59. Function DescendsFrom(Ancestor : TObject;Test : TObject):Boolean;
  60.  
  61. { Can we assign class2 to class1 ? }
  62. Function ClassAssignmentCompatible(Class1 , Class2 : TObject):boolean;
  63.  
  64. procedure SetEvent( ComponentWithEvent   : TComponent ;
  65.                     const Event          : string ;
  66.                     ComponentWithHandler : TComponent ;
  67.                     const Handler        : string ) ;
  68.  
  69.  
  70. Procedure GetProperties(AObj         : TObject;
  71.                         TypeKinds    : TTypeKinds;
  72.                         AList        : TStrings;
  73.                         iIndentLevel : Integer);
  74.  
  75.  
  76. Procedure GetComponentProperties(AObject      : TComponent;
  77.                                  TypeKinds    : TTypeKinds;
  78.                                  AList        : TStrings;
  79.                                  iIndentLevel : integer);
  80.  
  81. Procedure FreePropertyData( AList : TStrings );
  82.  
  83. function EnumValue(EnumType: PTypeInfo; const EnumName: string): Integer;
  84.  
  85. {*                                                                  *}
  86. { Do a recursive search from ROOT downward to see if EnumName exists }
  87. { as one of the members of an enumeration type                       }
  88. { If root is a component, search component list recursively also     }
  89. { Returns its ordinal value                                          }
  90. {*                                                                  *}
  91. Function FBGetEnumValue(Root               : TObject;
  92.                         Const EnumName     : String;
  93.                         var   Instance     : TObject;
  94.                         var   EnumTypeInfo : PTypeInfo):integer;
  95.  
  96. {*                                                                  *}
  97. { Do a recursive search from ROOT downward to see if PropName exists }
  98. { as one of the members of an object                                 }
  99. { If root is a component, search component list recursively also     }
  100.  
  101. Function FindPropInfo(Root               : TObject;
  102.                       Const PropName     : String;
  103.                       Const Kinds        : TTypeKinds;
  104.                       var   Instance     : TObject;
  105.                       var   APropInfo    : PPropInfo):boolean;
  106.  
  107.  
  108. {* Return Property info for a property given its Path from Root *}
  109. Function GetPropFromPath(Root         : TObject;
  110.                          PropPath     : string;
  111.                          var Instance : TObject) : PPRopInfo;
  112.  
  113.  
  114. { This function expects a list of identifiers separated by commas }
  115. Function StringSetToInt(root : TObject;SetString : String) : Cardinal;
  116.  
  117. Function  GetRTTIErrorText(ecode : integer):string;
  118.  
  119. procedure PropValueError;
  120. procedure PropertyNotFound;
  121. procedure PropPathError;
  122. Procedure InvalidPropertyError;
  123. Procedure PropReadOnlyError;
  124.  
  125. IMPLEMENTATION
  126. END.
  127.